package com.lf.enums;


import com.lf.exception.ApiException;

/**
 * The class Error code enum.
 */
public enum ErrorCodeEnum {

    /**
     * sex
     */
    WOMAN(0,"女"),
    MAN(1,"男"),
    UNKNOW(2,"未知"),

    /**
     * EXAMINE STATUS
     */
    SUCC(0,"审核成功"),
    FAIL(1,"审核被拒"),
    ING(2,"审核中"),
    BACK(3,"已撤回"),
    RELEASE(4,"已发布"),
    WAIT(5,"待审核"),


    /**
     * 全局通用
     */
    SC0(0, "成功"),
    SC1(1, "服务请求失败"),
    SC2(2, "调用宇链失败"),

    /**
     * 用户认证
     */
    TK1002(1002, "TOKEN解析失败"),
    TK1003(1003, "创建token失败"),
    TK1004(1004, "登录超时，请重新登录!"),
    TK1005(1005, "token已经过期，请重新登录!"),
    TK1006(1006, "验证token失败,请重新登录!"),
    TK1007(1007, "验证token失败"),
    TK1009(1009, "token不存在"),
    TK1010(1010, "shopId不存在"),
    TK1011(1011, "实名认证失败"),
    TK1012(1012, "用户被拉黑"),
    TK1013(1013, "注册短信验证码发送失败"),
    TK1014(1014, "修改密码短信验证码发送失败"),
    TK1015(1015, "短信验证码校验失败"),
    TK1016(1016, "密码不一致"),
    TK1017(1017, "已认证"),
    TK1018(1018, "已在别处登录"),
    TK1019(1019, "account不存在"),
    TK1020(1020, "身份证已被认证"),

    /**
     * 资金账户相关
     */
    TK2001(2001, "账户信息不存在"),
    TK2002(2002, "账户充值失败"),

    FL500(-500, "操作失败"),
    FL501(-501, "网络繁忙,请稍后重试"),

    SW10(-10, "[%s]错误"),
    SW11(-11, "参数[%s]不能为空"),
    SW12(-12, "[%s]失败"),

    SW20(-20, "用户名或密码不能为空"),
    SW30(-30, "密码错误"),
    SW40(-40, "两次密码不同"),
    SW50(-50, "用户不存在"),
    SW51(-51, "用户已存在"),
    SW52(-52, "支付密码错误"),
    SW53(-53, "手机号已被注册或不存在"),
    SW54(-54, "不能转给自己"),

    SW100(-100, "参数错误"),
    SW200(-200, "超管不能操作"),

    SW300(-300, "上传文件格式不正确"),
    SW301(-301, "导入失败,%s"),
    SW302(-302, "积分不足"),

    CE401(-401, "渠道名称已存在"),
    SE601(-601, "小程序名称已存在"),



    /**
     * 优惠券相关
     */
    CP6001(6001, "优惠券剩余库存不足"),
    CP6002(6002, "[%s]不存在"),
    CP6003(6003, "不允许库存从不限数量改为固定总数"),
    CP6004(6004, "限制数量的总库存不能为空"),
    CP6005(6005, "优惠券名称已存在"),
    CP6006(6006, "优惠券已不可用"),
    CP6007(6007, "优惠券发放失败，未找到可发放的人员信息"),
    CP6008(6008, "优惠券不支持转增"),
    CP6009(6009, "自己不能领取"),
    CP6010(6010, "优惠券已被领取"),



    /**
     * 验证相关
     */
    SW400(400, "无效的短信验证码"),
    SW401(401, "短时间不要频繁获取验证码"),
    /**
     * 支付相关
     */
    ZF5000(5000, "支付金额有误"),
    ZF5001(5001, "余额不足"),


    UP9001(-9001, "签名生成失败"),
    UP9002(-9002, "银联接口调用失败"),
    UP9003(-9003, "银联接口请求失败"),
    UP9004(-9004, "请求参数转化失败"),

    WP8001(-8001, "微信支付-商铺信息未配置"),
    WP8002(-8002, "微信支付-商铺微信信息未配置"),
    WP8003(-8003, "微信支付-商铺小程序信息未配置"),
    WP8004(-8004, "微信支付-商铺商户信息未配置"),
    WP8005(-8005, "微信支付-会员信息未获取"),
    WP8006(-8006, "微信支付-会员openid不存在"),
    WP8007(-8007, "微信支付-接口失败"),
    WP8008(-8008, "微信支付-宇链商户号未配置"),
    WP8009(-8009, "获取小程序模板失败"),
    WP8010(-8010, "统一下单接口调用失败"),
    WP8011(-8011, "微信支付-回调金额不一致"),
    WP8012(-8012, "微信支付订单查询失败,失败原因:[%s]"),
    WP8013(-8013, "微信支付订单不存在"),
    WP8014(-8014, "微信提现金额超限,最低1元,最高10万"),
    WP8015(-8015, "提现异常,联系客服QQ:2602685638"),
    WP8016(-8016, "提现失败,请稍后重试"),
    WP8017(-8017, "微信支付回调通信异常"),
    WP8018(-8018, "订单不存在"),
    WP8019(-8019, "订单已成功,无需重试"),
    WP8020(-8020, "参数/配置有误，请查验修正"),
    WP8021(-8021, "提现失败,联系客服QQ:2602685638"),
    WP8022(-8022, "已提现,留意微信到账通知,客服QQ:2602685638"),


    WX1(-1, "系统繁忙，请稍候再试"),
    WX40029(40029, "code无效"),
    WX45011(45011, "频率限制，每个用户每分钟100次"),
    WX_SIGNATURE(45012, "微信签名失败"),
    WX_SIGN_DIFF(45013,"签名不一致"),
    WX_RESULT_CODE_FAILD(45014,"微信支付回调失败"),


    WC10001(10001, "商铺已创建会员卡"),
    WC10002(10002, "商铺创建会员卡失败"),
    WC10003(10003, "商铺修改会员卡失败"),
    WD11001(11001, "生成小程序码失败"),

    /**
     * 分销模块 7100开头
     */
    DB_USER_NOT_EXISTS(710001, "分销用户信息不存在"),
    DB_TEMPATE_NOT_EXISTS(710002, "商户未设置分销模板信息"),
    DB_SHAREPOP_NOT_EXISTS(710003, "商户未设置分销比例信息"),
    DB_TEMPATE_CLOSED(710004, "商户分销设置已关闭"),
    CARE_LEVEL_NOT_EXISTS(710005, "商户会员等级不存在"),

    /**
     * 店铺相关
     */
    SHOP_NOT_EXISTS(720001,"店铺信息不存在"),


    /**
     * 活动相关
     */
    ACTIVITY_NOT_EXISTS(110001,"活动信息不存在"),
    ACTIVITY_NOT_FIT(110002,"活动信息不符合"),

    /**
     * 参数相关
     */
    PARAM_200001(200001,"请输入正确的手机号码"),
    PARAM_200002(200002,"请输入6-12位字母+数字用户名"),
    PARAM_200003(200003,"请输入6-12位字母+数字密码"),
    PARAM_200004(200004,"请输入正确的身份证"),
    PARAM_200005(200005,"请输入正确的验证码"),
    PARAM_200006(200006,"[%s]不能为空"),
    PARAM_200007(200007,"用户等级不可以购买该升级套餐"),
    PARAM_200008(200008,"信息不正确"),
    PARAM_200009(200009,"调用频率过高"),
    PARAM_200010(200010,"数据服务异常"),
    PARAM_200011(200011,"实名认证失败"),
    PARAM_200012(200012,"发送验证码失败"),
    PARAM_200013(200013,"%s不是有效自然数"),
    PARAM_200014(200014,"[RD系统- %s -接口请求失败]"),
    PARAM_200015(200015,"不能发货"),
    PARAM_200016(200016,"请输入6-12位字母+数字邀请码"),
    PARAM_200017(200017,"邀请码不存在"),
    PARAM_200018(200018,"直推人数不达标"),
    PARAM_200019(200019,"团队人数不达标"),
    PARAM_200020(200020,"发放数量错误"),
    PARAM_200021(200021,"账号格式错误"),
    PARAM_200022(200022,"实名认证接口异常"),
    PARAM_200023(200023,"目标星级参数异常"),
    PARAM_200024(200024,"实名认证接口调用次数达到上限"),
    PARAM_200025(200025,"邀请码无效"),
    PARAM_200026(200026,"收账手机号不存在"),
    PARAM_200027(200027,"登录失败"),
    PARAM_200028(200028,"RD不足手续费"),
    PARAM_200029(200029,"请升级至一星消费商后兑换"),
    PARAM_200030(200030,"无权限操作"),
    PARAM_200031(200031,"授权码已过期"),
    PARAM_200032(200032,"用户未人脸核身"),
    PARAM_200033(200033,"授权码格式错误"),
    PARAM_200034(200034,"用户名格式错误"),
    PARAM_200035(200035,"用户ID格式错误"),
    PARAM_200036(200036,"请注意：授权码填写有误,或是虚假授权码"),
    PARAM_200037(200037,"请注意：姓名/授权码校验错误"),
    PARAM_200038(200038,"核查费用 FEE元/月"),
    PARAM_200039(200039,"核查到期续费 FEE元/月"),
    PARAM_200040(200040,"自己不能吐槽自己"),
    PARAM_200041(200041,"您已是代理商"),
    PARAM_200042(200042,"禁止操作"),
    PARAM_200043(200043,"审核中，请勿重复提交"),
    PARAM_200044(200044,"提现余额不得低于100元"),
    PARAM_200045(200045,"手机号实名信息和身份证信息不匹配"),
    PARAM_200046(200046,"代理商到期"),
    PARAM_200047(200047,"系统维护中,不便之处请谅解"),
    PARAM_200048(200048,"系统维护,请择日提现"),
    PARAM_200049(200049,"未实名,无法提现"),
    PARAM_200050(200050,"您已吐槽过他/她"),
    PARAM_200051(200051,"高于10000元,请联系QQ客服提现:2602685638"),

    AUTH_1(1,"信息一致，匹配成功"),
    AUTH_2(2,"信息不匹配"),
    AUTH_30(30,"未开通无卡支付"),
    AUTH_31(31,"此卡被没收"),
    AUTH_32(32,"无效卡号"),
    AUTH_33(33,"此卡无对应发卡行"),
    AUTH_34(34,"此卡未初始化或睡眠卡"),
    AUTH_35(35,"作弊卡，吞卡"),
    AUTH_36(36,"此卡已挂失"),
    AUTH_37(37,"此卡已过期"),
    AUTH_38(38,"密码错误次数超限"),
    AUTH_39(39,"发卡行不支持此交易，请联系发卡行"),
    AUTH_40(40,"受限制的卡，建议换卡"),


    AUTH_CODE_400(400,"参数异常"),
    AUTH_CODE_401(401,"账号异常"),
    AUTH_CODE_403(403,"调用异常"),
    AUTH_CODE_404(404,"路径异常"),
    AUTH_CODE_500(500,"内服服务异常"),
    ;

    private int code;

    private String msg;

    ErrorCodeEnum(int code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static ApiException ThrowParamsException(String feildName) {
        throw new ApiException(ErrorCodeEnum.FL500.code(), String.format(ErrorCodeEnum.FL500.msg(), feildName));
    }

    /**
     * Gets enum.
     *
     * @param code the code
     * @return the enum
     */
    public static ErrorCodeEnum getEnum(int code) {
        for (ErrorCodeEnum ele : ErrorCodeEnum.values()) {
            if (ele.code() == code) {
                return ele;
            }
        }
        return null;
    }

    /**
     * Msg string.
     *
     * @return the string
     */
    public String msg() {
        return msg;
    }

    /**
     * Code int.
     *
     * @return the int
     */
    public int code() {
        return code;
    }
}
